import api from '../index'

export interface TranslationResult {
  trans_result: {
    src: string
    dst: string
  }[]
}

export default {
  /**
   * 调用百度翻译API
   * @param params - 翻译参数
   * @param params.query - 要翻译的文本
   * @param params.from - 源语言
   * @param params.to - 目标语言
   * @returns 翻译结果
   */
  translate: (params: { query: string, from: string, to: string }) =>
    api.get<TranslationResult>('/baidu/transApi', {
      params: {
        query: params.query,
        from: params.from,
        to: params.to,
      },
    }),
}
